package com.xm.settlement.service.impl;

import com.baomidou.framework.service.impl.SuperServiceImpl;
import com.baomidou.mybatisplus.plugins.Page;
import com.xm.settlement.commons.utils.PageInfo;
import com.xm.settlement.mapper.AppServiceMapper;
import com.xm.settlement.model.AppService;
import com.xm.settlement.service.IAppServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2017/3/2.
 */
@Service
public class AppServiceServiceImpl extends SuperServiceImpl<AppServiceMapper,AppService> implements IAppServiceService {

    @Autowired
    private AppServiceMapper appServiceMapper;


    @Override
    public void selectDataGrid(PageInfo pageInfo,Long Lid) {
        Page<AppService> page = new Page<AppService>(pageInfo.getNowpage(), pageInfo.getSize());
        List<AppService> list = appServiceMapper.selectAppServiceList(page,Lid);
        pageInfo.setRows(list);
        pageInfo.setTotal(page.getTotal());
    }

    @Override
    public void addService(AppService appService) {
        appService.setCreateId(appService.getUpdateId());
        appService.setCreateTime(new Date());
        Integer code = appServiceMapper.selectServiceCode();
        appService.setServiceCode(code==null?0:code+1);
        appServiceMapper.insert(appService);
    }
}
